<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : teamProgressChart.xsl
    Created on : 2010-04-27, 17:23
    Author     : Football-Statistics Team
    Description: transforms data to a google chart
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="text" media-type="html/text"/>
    <xsl:param name="team"/>
    <xsl:param name="loc_round"/>
    <xsl:param name="loc_position"/>
    <xsl:param name="loc_team_progress"/>
    <xsl:template match="/teams-progress">
        <xsl:text>google.load("visualization", "1", {packages:["corechart"]});</xsl:text>
        <xsl:text>google.setOnLoadCallback(drawChart);</xsl:text>
        <xsl:text>function drawChart() {</xsl:text>
        <xsl:text>var data = new google.visualization.DataTable();</xsl:text>
        <xsl:text>data.addColumn('string', '</xsl:text><xsl:value-of select="$loc_round"/><xsl:text>');</xsl:text>
        <xsl:text>data.addColumn('number', '</xsl:text><xsl:value-of select="$team"/><xsl:text>');</xsl:text>
        <xsl:for-each select="round">
            <xsl:text>data.addRow(['</xsl:text><xsl:value-of select="@number"/><xsl:text>', </xsl:text>
            <xsl:for-each select="team">
                <xsl:if test="@name=$team">
                    <xsl:value-of select="position()"/><xsl:text>]);</xsl:text>
                </xsl:if>
            </xsl:for-each>
        </xsl:for-each>
        <xsl:text>var chart = new google.visualization.LineChart(document.getElementById('chart_div'));</xsl:text>
        <xsl:text>chart.draw(data, {width: 800, height: 600, backgroundColor: '#f5f5f5', title: '</xsl:text><xsl:value-of select="$loc_team_progress"/><xsl:text>', hAxis: {title: '</xsl:text><xsl:value-of select="$loc_round"/><xsl:text>'}, vAxis: {title: '</xsl:text><xsl:value-of select="$loc_position"/><xsl:text>', direction: -1, minValue: 1, maxValue:</xsl:text><xsl:value-of select="count(round[@number=1]/team)"/><xsl:text>, format: '##.', baseline: 0}});</xsl:text>
        <xsl:text>}</xsl:text>
    </xsl:template>
</xsl:stylesheet>
